package com.gxa.controller.department;


import com.gxa.common.R.ResponseData;
import com.gxa.pojo.Dept;
import com.gxa.service.department.DeptService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/*
1.3添加部门
*/
@Controller
@Api(value = "添加部门test",tags = "添加部门接口API")
@RequestMapping("/dept")
public class DeptAddController {
    @Autowired
    private DeptService deptService;//调用service层接口

    //1.3.1添加部门信息
    @RequestMapping(value = "/insertDepartment",method = RequestMethod.POST)
    @ApiOperation(value = "添加部门信息",notes = "录入部门的基本信息",httpMethod = "POST", response = ResponseData.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public ResponseData InsertDepartment(@RequestBody Dept dept){
        return deptService.insertDepartment(dept);

    }
    //1.3.2 选择部门等级(下拉框)
    @RequestMapping(value ="/chooseDepartment" ,method = RequestMethod.GET)
    @ApiOperation(value = "选择部门下拉框",notes = "从数据库中返回所有部门名称用于渲染所在部门下拉多选框",httpMethod = "get", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "部门等级",required = true, dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public ResponseData ChooseDepartment(@RequestParam int type){
        return deptService.chooseDepartment(type);
    }
}
